<?php
  include_once $_SERVER['DOCUMENT_ROOT'].'/PariGest/pages/inc/entete.php';
  require_once $REP_CLASS . 'class.Operation.php';
  require_once $REP_CLASS . 'class.Parametrage.php';
  
  include $REP_PAGES . 'IncSelectCompte.php';
  
  try
  {
    /*$parametrage = new Parametrage($db);
    
    $parametrage->setIdCompte($IdCompte);
    $parametrage->affichage();*/
    
   if( $action == 'UPDATE' )
   {
     $operation = new Operation($db);
     $operation->setIdType(getChaineNotNullSinon("LstTypeOp",""));
     $operation->setDate(convMajDate(getChaineNotNullSinon("Date","")));
     $operation->setCommentaire(getChaineNotNullSinon("Commentaire",""));
     $operation->setIdCompte($IdCompte);
     $operation->setLibelle(getChaineNotNullSinon("Libelle",""));
     $operation->setMontant(getChaineNotNullSinon("Montant",""));
     $operation->insertion();
   }

   $operation = new Operation($db);
   $operation->setIdCompte($IdCompte);
   $stmt = $operation->select();
   $lstOp = $stmt->fetchAll(); 
   
   $trace->fb('Avant le commit');
   $db->commit();
   $trace->fb('Apres le commit');

   $lstTypeOp = Operation::selectAllTypes();
  }
  catch(MyException $e)
  {
    $trace->fb('!!!!! ERREUR !!!!!');
    include $_SERVER['DOCUMENT_ROOT'].'/PariGest/pages/inc/catch.php';
  }
  $smarty->assign('REP_PAGES', $REP_PAGES);
  $smarty->assign('DateDuJour', getDateToday());
  $smarty->assign('LstTypeOp', $lstTypeOp);
  $smarty->assign('LstTypeOpSelected', Operation::$ID_TYPE_DEPOT);
  $smarty->assign('LstOp', $lstOp);
  $smarty->display('gestionParis.tpl');
?>
